﻿// Example header text. Can be configured in the options.
using System;
using System.Linq;

namespace vtech_frameWorks.Library
{
    public class ClsNullableDate
    {
        // Fields
        public bool IsNull;

        // Methods
        public ClsNullableDate()
        {
            this.IsNull = true;
            this.Date = DateTime.Now;
            this.IsNull = true;
        }

        public ClsNullableDate(DateTime initDateTime)
        {
            this.IsNull = true;
            this.Date = initDateTime;
            this.IsNull = false;
        }

        public string ToFulltimeVnFormat()
        {
            if (this.IsNull)
            {
                return "NULL";
            }
            return string.Format("{0}/{1}/{2} {3}:{4}:{5}", new object[] { this.Date.Day, this.Date.Month, this.Date.Year, this.Date.Hour, this.Date.Minute, this.Date.Second });
        }

        public override string ToString()
        {
            if (this.IsNull)
            {
                return "NULL";
            }
            return string.Format("'{0}'", this.Date.ToString("yyyyMMdd HH:mm:ss:fff"));
        }

        public string ToVnFormat()
        {
            if (this.IsNull)
            {
                return "NULL";
            }
            return string.Format("{0}/{1}/{2}", this.Date.Day, this.Date.Month, this.Date.Year);
        }

        // Properties
        public DateTime Date { get;private set; }
    }
}